#include <bits/stdc++.h>
using namespace std;
#define int long long

template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    return os << '(' << p.first << ", " << p.second << ')';
}
template<typename C,typename D = typename enable_if <!is_same<C, string>::value,typename C::value_type>::type>
ostream &operator<<(ostream &os, const C &v)
{
    os << '{';
    string sep;
    for (const D &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}

void dbg_out()
{
    cerr << endl;
}
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int ____________________CYCLE____________________;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define inf INT32_MAX
#define i64 int64_t
const int N = 1e5;

signed main(){
    int n,x;
    cin >> n >> x;
    int a[n + 5] = {0};
    rep(i,1,n){
        int z;
        cin >> z;
        z = z - x;
        a[i] = z;
    }
    int maax = 0;
    int sum = 0;
    /* rep(i,1,n){
        cout << a[i] << " ";
    }
    cout << endl; */
    rep(i,1,n){
        sum += a[i];
        if(sum > maax){
            maax = sum;
        }
        if(sum < 0){
            sum = 0;
        }
    }
    cout << maax;
}